﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WS.EKA.Business.Service
{
    public class ServiceFactory
    {
        public static IService CreateService(string target)
        {
            ServiceType service=(ServiceType)Enum.Parse(typeof(ServiceType),target.ToUpper());
            switch (service)
            {
                case ServiceType.EVENT:
                    return new EventService();
                case ServiceType.APPLICATION:
                    return new ApplicationService();
                case ServiceType.INCIDENT:
                    return new IncidentService();
                default:
                    break;
            }
            return null;
        }

        public static IService<T> CreateService<T>()
        {
            string[] names = typeof(T).Name.Split('_');
            var instance =  CreateService(names[1]);
            return instance as IService<T>;
        }
    }

    public enum ServiceType
    { 
        EVENT,
        INCIDENT,
        APPLICATION
    }
}
